package com.chapter16;

import java.util.*;

public class PalindromicDecomposition {

	public void decompose(String s,int index,List<String> l){
		if(index==s.length()){
			System.out.println(l);
			return;
		}
		int mid=index;
		for(int i=index;i<s.length();i++){
			int p=2*mid-i;
			if(p<0)
				p=index;
			if(s.charAt(i)==s.charAt(p) && p==index){
				l.add(s.substring(index, i+1));
				decompose(s,i+1,l);
				l.remove(l.size()-1);
			}
			else if(s.charAt(i)==s.charAt(p))
				continue;
			else
				mid=i;
		}
	}
	
	public void testDecompose(){
		String s="aabcb";
		List<String> l=new ArrayList<String>();
		decompose(s,0,l);
	}
	
	
}
